/*
 * Copyright (C) 2025 Tsingteng MicroSystem
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _NFC_LOG_IMPL_
#define _NFC_LOG_IMPL_

#include "hilog/log.h"

/**
 * @file nfc_log_impl.h
 * @brief OHOS系统中日志打印功能实现
*/
#undef LOG_DOMAIN
#undef LOG_TAG
#define LOG_DOMAIN 0xD000302
#define LOG_TAG TAG

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

void PrintOhosLog(int logLevel, const char* fileName, const char* function, int line, const char* logMessage);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#define OS_PRINT(log_level, fmt, ...) \
{ \
    char *log_message = NULL; \
    if (asprintf(&log_message, fmt, ##__VA_ARGS__) < 0) { \
        HILOG_ERROR(LOG_CORE, "%{public}s", "Failed to calculate log message size."); \
    } else { \
        PrintOhosLog((int) (log_level), __FILENAME__, __FUNCTION__, __LINE__, log_message); \
    } \
    if (log_message) free(log_message); \
}

#endif /* _NFC_LOG_IMPL_ */